<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易ATM</title>
</head>

<body>
    <script>
        let yu_e = 2000;
        while (true) {
            let num = +prompt("请选择操作:\n" + "1存钱\n" + "2.取钱\n" + "3.查询余额\n" + "4.退出\n")
            // if (num == 1) {
            //     let cun = +prompt("输入存钱金额")
            //     yu_e = yu_e + cun;
            //     alert("存钱成功！")
            //     break;
            // }
            switch (num) {
                case 1:
                    let cun = +prompt("输入存钱金额")
                    yu_e = yu_e + cun
                    alert("存钱成功，已存入" + cun + "元." + "余额为：" + yu_e + "元")
                    break;
                case 2:
                    let qu = +prompt("请输入取钱金额")
                    if (qu > yu_e) {
                        alert("余额不足")
                        break;
                    }
                    else {
                        yu_e = yu_e - qu;
                        alert("取钱成功，已取出" + qu + "元。" + "余额为：" + yu_e + "元")
                        break;
                    }
                case 3:
                    alert("余额为：" + yu_e + "元")
                    break;

            }
            if (num == 4) {
                alert("欢迎再次使用！")
                break;
            }
            else {
                alert('请输入正确的数字')
            }

        }
    </script>
</body>

</html>